package xia.wan.reptile;

import cn.hutool.http.HttpUtil;
import xia.wan.reptile.entity.Chapter;
import xia.wan.reptile.entity.ComicPage;
import xia.wan.reptile.util.HttpChapter;
import xia.wan.reptile.util.HttpComicPage;

import java.util.List;

/**
 * @program: reptile
 * @interfaceName Main
 * @description: 启动类
 * @author: 太白
 * @create: 2022-12-14 18:15
 **/
public class Main {


    public static void main(String[] args) {
        HttpChapter httpChapter = new HttpChapter();
        HttpComicPage httpComicPage = new HttpComicPage();
        List<Chapter> chapters = httpChapter.gainChapter();
        System.out.println(chapters.size());

        for (int i = 0; i < chapters.size(); i++) {

            Chapter chapter = chapters.get(i);
            List<ComicPage> comicPages = httpComicPage.gainChapter(chapter);
            System.out.println(comicPages.size());
            for (int j = 0; j < comicPages.size(); j++) {
                ComicPage comicPage = comicPages.get(j);
                System.out.println(comicPage.getName()+"----"+comicPage.getUrl());
                try {
//                    Thread.sleep(1000);
                    HttpUtil.downloadFile(comicPage.getUrl(),"E:\\lovejava\\fool-around\\reptile\\src\\main\\resources\\"+chapter.getName()+"\\"+comicPage.getName()+".jpg");

                }catch (Exception e){

                }

            }
        }


    }
}
